﻿@page
@model LiuQiuRong.Chat.Web.Pages.RegisterModel
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta charset="utf-8">
    <title>Web 聊天室</title>
    <meta name="description" content="particles.js is a lightweight JavaScript library for creating particles.">
    <meta name="author" content="Vincent Garreau" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
    <link href="~/lib/layui/css/layui.css" rel="stylesheet" />
    <link rel="stylesheet" media="screen" href="~/css/chat.css">
    <link rel="stylesheet" type="text/css" href="~/css/login_reset.css" />

</head>
<body>

    <div id="particles-js">
        <div class="login">
            <div class="login-top">
                注册
            </div>
            <div class="login-center clearfix">
                <div class="login-center-img"><img src="~/imgs/name.png" /></div>
                <div class="login-center-input">
                    <input type="text" name="" id="txtAccount" value="" placeholder="请输入您的账号" asp-for="Account" onfocus="this.placeholder=''" onblur="this.placeholder='请输入您的账号（手机号码）'" />
                    <div class="login-center-input-text">手机号</div>
                </div>
            </div>
            <div class="login-center clearfix">
                <div class="login-center-img"><img src="~/imgs/name.png" /></div>
                <div class="login-center-input">
                    <input type="text" name="" id="txtUserName" value="" placeholder="请输入您用户名" asp-for="UserName" onfocus="this.placeholder=''" onblur="this.placeholder='请输入您的账号（手机号码）'" />
                    <div class="login-center-input-text">用户名</div>
                </div>
            </div>
            <div class="login-center clearfix">
                <div class="login-center-img"><img src="~/imgs/password.png" /></div>
                <div class="login-center-input">
                    <input type="password" name="" id="txtPassword" value="" placeholder="请输入您的密码" asp-for="PassWord" onfocus="this.placeholder=''" onblur="this.placeholder='请输入您的密码'" />
                    <div class="login-center-input-text">密码</div>
                </div>
            </div>
            <div class="login-center clearfix">
                <div class="login-center-img"><img src="~/imgs/password.png" /></div>
                <div class="login-center-input">
                    <input type="password" name="" id="txtRePassword" value="" placeholder="请输入您的确认密码" asp-for="RePassWord" onfocus="this.placeholder=''" onblur="this.placeholder='请输入您的密码'" />
                    <div class="login-center-input-text">确认密码</div>
                </div>
            </div>
            <div id="chat_btnregister" class="login-button">
                注册
            </div>
        </div>
        <div class="sk-rotating-plane"></div>
    </div>

    <!-- scripts -->
    <script src="~/js/login_particles.min.js"></script>
    <script src="~/js/login_app.js"></script>
    <script src="~/lib/jquery/dist/jquery.min.js"></script>
    <script src="~/lib/layui/layui.js"></script>
    <script>
        $(function () {
            layui.use('form', function () {
                var form = layui.form, layer = layui.layer;
                form.render();

                $("#chat_btnregister").on("click", function () {
                    var account = $("#txtAccount").val();
                    var userName = $("#txtUserName").val();
                    var rePassword = $("#txtRePassword").val();
                    var password = $("#txtPassword").val();
                    if (account === "") {
                        layer.tips('请输入账号！', '#txtAccount', {
                            tips: [1, '#fe9913']
                        });
                        return false;
                    }
                    if (userName === "") {
                        layer.tips('请输入用户名！', '#txtUserName', {
                            tips: [1, '#fe9913']
                        });
                        return false;
                    }
                    if (password === "") {
                        layer.tips('请输入密码！', '#txtPassword', {
                            tips: [1, '#fe9913']
                        });
                        return false;
                    }
                    if (rePassword === "") {
                        layer.tips('请输入确认密码！', '#txtRePassword', {
                            tips: [1, '#fe9913']
                        });
                        return false;
                    }
                    if (rePassword !== password) {
                        layer.tips('两次输入的密码不一样！', '#txtRePassword', {
                            tips: [1, '#fe9913']
                        });
                        return false;
                    }

                    $.ajax({
                        url: "/Register?handler=Submit",
                        data: {
                            Account: account,
                            PassWord: password,
                            UserName: userName
                        },
                        type: 'post',
                        dataType: 'json',
                        beforeSend: function (xhr) {
                            //that.load("正在提交数据操作");
                        },
                        success: function (data, textStatus) {
                            if (data.status === "y") {
                                layer.msg(data.info);
                                //wlg.load("登录成功，正在进入系统");
                                window.onbeforeunload = null;
                                window.location.href = "/login";
                            }
                            else {
                                layer.msg(data.info);
                            }
                        },
                        error: function (xhr, status, error) {
                            //that.error("程序异常，请联系服务商。");
                        },
                        complete: function (xhr, status) {
                            // that.closeLoad();
                        }
                    });
                });


            });
        });
    </script>
</body>
</html>
